package com.qf.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qf.search.api.ISearchService;
import com.qf.search.api.entity.TProductSearchDto;
import com.team5101.vo.ResultBean;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/search")
public class SearchController {

    @Reference
    private ISearchService iSearchService;



    @RequestMapping("")
    @ResponseBody
    public ResultBean searchByKeywords(String keyword) {
        ResultBean resultBean = iSearchService.searchByKeyword(keyword);
        if (resultBean.getData()==null||!resultBean.getData().equals("")){
            return ResultBean.error(null,"搜索内容为空");
        }
        //model.addAttribute("products", resultBean.getData());
        return ResultBean.success(resultBean.getData(),"查询成功");

    }

    @RequestMapping("/addAll")
    @ResponseBody
    public ResultBean addAll(){
      return iSearchService.selectAll();
    }


}